import java.util.Scanner;
public class OJqiguaideshulie {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = 1;
        String str = sc.next();
        String str1 =sc.next();
        int m = sc.nextInt();
        while (m != 0) {
            String s = "";
            for (int i = 0; i < str.length(); i++) {
                if (i+1 < str.length() && str.charAt(i) == str.charAt(i+1)) {
                    a++;
                    continue;
                }
                s += a + "" + str.charAt(i) ;
                a = 1;
            }
            str = s;
            m--;
        }
        System.out.println(str);
    }

}
